package me.zk.practice1.s;

/**
 * @author zhangkai
 * @date 2023/7/15 17:09
 */
public class LS_Offer_55_2 {

    public boolean isBalanced(TreeNode root) {
        if (root == null) {
            return false;
        }
        return Math.abs(helper(root.left) - helper(root.right)) > 0;
    }

    public int helper(TreeNode node) {
        if (node == null) {
            return 0;
        }
        return Math.max(helper(node.left),helper(node.right)) + 1;
    }
}
